import React, { useEffect, useState } from 'react'
import { Button, Input, Space, message, Form, Col, Row } from 'antd'
import ProForm, {
  ProFormSelect,
  ProFormText,
  ProFormSwitch,
  ProFormTextArea,
} from '@ant-design/pro-form'

import { getAgentPagetList } from '../service'

const ModelSetting: React.FC<{ copilotInfo: any }> = ({ copilotInfo }) => {
  const [copilotForm] = Form.useForm()

  // 查询Copilot信息
  useEffect(() => {
    console.log('copilotInfo:', copilotInfo)
  }, [copilotInfo])

  const handleFinish = async () => {
    copilotForm
      .validateFields()
      .then(async () => {
        var response = copilotForm.getFieldsValue()
        console.log(response)
        message.success('模型设置已更新')
      })
      .catch(() => { })
  }

  const titleStyle = {
    marginBottom: '12px',
    fontWeight: '500',
    fontSize: '20px',
    lineHeight: '28px',
  }

  return (
    <>
      <div style={titleStyle}>模型设置</div>
      <ProForm
        layout="vertical"
        onFinish={handleFinish}
        submitter={{
          searchConfig: {
            submitText: '更新模型设置',
          },
          render: (_, dom) => dom[1],
        }}
        initialValues={{
          ...copilotInfo,
        }}
        form={copilotForm}
      >
        <ProFormText width="md" name="serialNo" label="智能体ID" disabled />
        <ProFormSwitch
          width="md"
          name="editable"
          label="是否可编辑"
          disabled
          tooltip="系统配置不支持编辑和删除"
        />
        <ProFormText
          width="md"
          name="model"
          label="模型名称"
          placeholder="请输入模型名称"
        />
        <ProFormTextArea
          name="systemPrompt"
          label="系统提示词"
          placeholder="请输入系统提示词"
          fieldProps={{ rows: 4 }}
        />
      </ProForm>
    </>
  )
}

export default ModelSetting
